import send_msg from '@feidao-factory/send-msg/browser';

const JS_CUSTOM_SERVICE = 'dataservice.nodejs';

export default function service<T>(spaceid: string, name: string, ...args: any[]) {
	const param = { modelid: 'custom::js_invoke-atom', spaceid, name, args };
	return send_msg(JS_CUSTOM_SERVICE, param, false, false)
		.catch((e) => {
			console.error(`--调用服务${JS_CUSTOM_SERVICE}失败--错误信息---`, e ? e.toString() : '');
			// const err = e ? e.toString() : '';
			return Promise.reject(e);
		}) as Promise<T>;
}
